import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

months = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
sales = [145.22, 118.63, 131.27, 124.26, 116.51, 108.11, 121.62, 111.74, 134.29, 137.28, 119.55, 146.87]

plt.figure(figsize=(10, 6), facecolor='#2E4057')
ax = plt.gca()
ax.set_facecolor('#2E4057')

# 绘制折线图
plt.plot(months, sales, color='#4F81BD', marker='o', linewidth=2)

# 填充区域
plt.fill_between(months, sales, color='#4F81BD', alpha=0.5)

plt.title("各月销售额(万)", fontsize=22, color='white', pad=20)
plt.xticks(fontsize=20, color='white')
plt.yticks(fontsize=20, color='white')
plt.ylabel("销售额(万)", fontsize=20, color='white')
plt.xlabel("月份", fontsize=20, color='white')

# 隐藏边框
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)

#调整 y 轴范围
plt.ylim(0, 200)

#添加网格线
plt.grid(axis='y', color='gray', linestyle='--', linewidth=0.5, alpha=0.5)

#调整布局
plt.tight_layout()

plt.savefig(r'D:\python charm\01\可视化\销售看板参考\图片\各月销售额.png')

plt.show()